import json
from kafka import KafkaProducer, KafkaConsumer
import time

# 数据
data = {}

if __name__ == '__main__':

    # consumer = KafkaConsumer('v2x-quality-prometheus-rscu-online-status',
    #                          bootstrap_servers=['10.138.56.210:8092','10.138.56.210:8093','10.138.56.210:8094'],
    #                          auto_offset_reset='earliest'
    #               )
    producer = KafkaProducer(bootstrap_servers=['kafka:9092'])

    res = []
    for msg in data:
        msg = json.loads(msg.value)
        print()
        time_res = format(time.time(), '.3f')
        msg['value'][0] = time_res
        print(msg)
        data = json.dumps(msg).encode()
        producer.send('v2x-quality-prometheus-rscu-online-status', value=data)
        # print(111)
        # print(msg)